var mySqrt = function (x) {
    if (x === 0) return 0
    let left = 1
    let right = x
    let ans = 0
    while (left <= right) {
        let mid = Math.floor((left + right) / 2)
        if (mid * mid === x) {
            return mid
        } else if (mid * mid < x) {
            //  +1之后的平方根比x大所以ans就是mid
            ans = mid
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
};
const result = mySqrt(10)
console.log("🚀 ~ result:", result)
